package exception;

public class FinallyDemo {
    public static void main(String[] args) {
        System.out.println("程序开始了");
        try {
            String str=null;
            System.out.println(str.length());
            String str1="123";
            System.out.println(str1.charAt(5));
        }/*catch (StringIndexOutOfBoundsException e){
            System.out.println("字符串索引越界");
        }catch (NullPointerException e){
            System.out.println("空指针异常");
        }*//*catch (StringIndexOutOfBoundsException|NullPointerException e){
            System.out.println("字符串索引越界或空指针异常");
        }*/catch (Exception e){
            System.out.println("其他异常");
        }finally{
            System.out.println("finally代码块");
        }
        System.out.println("程序结束了");
    }
}
